package cn.yunhe.crm.controller;


import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.yunhe.crm.service.AftersaleService;
import cn.yunhe.crm.service.BproductService;
import cn.yunhe.crm.service.BusinessService;
import cn.yunhe.crm.service.ContractService;
import cn.yunhe.crm.service.DatainfoService;
import cn.yunhe.crm.service.DiaryService;
import cn.yunhe.crm.service.EmpService;
import cn.yunhe.crm.service.OrganizationService;
import cn.yunhe.crm.service.TasklistService;

@Controller
public class Demo {
	
	@Autowired
	@Qualifier("OrganizationService")
	private OrganizationService organService;

	public void setOrganService(OrganizationService organService) {
		this.organService = organService;
	}
	
	@Autowired
	@Qualifier("EmpService")
	private EmpService eService;
	
	public void seteService(EmpService eService) {
		this.eService = eService;
	}
	@Autowired
	@Qualifier("ContractService")
	private ContractService contractbiz;
	public void setContractbiz(ContractService contractbiz) {
		this.contractbiz = contractbiz;
	}
	@Autowired
	@Qualifier("DiaryService")
	private DiaryService dService;
	
	public void setdService(DiaryService dService) {
		this.dService = dService;
	}
	@Autowired
	@Qualifier("TasklistService")
	private TasklistService tService;
	
	public void settService(TasklistService tService) {
		this.tService = tService;
	}
	@Autowired
	@Qualifier("AftersaleService")
	private AftersaleService aService;
	
	public void setaService(AftersaleService aService) {
		this.aService = aService;
	}
	@Autowired
	@Qualifier("BusinessService")
	private BusinessService bService;
	
	public void setbService(BusinessService bService) {
		this.bService = bService;
	}
	@Autowired
	@Qualifier("bproductbiz")
	private BproductService bpService;

	public void setBpService(BproductService bpService) {
		this.bpService = bpService;
	}
    @Autowired
    @Qualifier("datainfoService")
    private DatainfoService dfService;
        
	public void setDfService(DatainfoService dfService) {
		this.dfService = dfService;
	}
	/**
	 * 跳转至main页面
	 * @return
	 */
	@RequestMapping("main.do")
	public String tomain(){
		return "redirect:inc/main.jsp";
	}

	/**
	 * 跳转至index页面
	 * @return
	 */
	@RequestMapping("index.do")
	public String tomain(HttpSession session){
		/**
		 * 机构总数量
		 */
		int ocount=organService.checkCount();
		session.removeAttribute("ocount");
		session.setAttribute("ocount",ocount);
		/**
		 * 员工总数量
		 */
		int ecount=eService.checkcount();
		session.removeAttribute("ecount");
		session.setAttribute("ecount", ecount);
		/**
		 * 合同总数量
		 */
		int ccount=contractbiz.checkCount();
		session.removeAttribute("ccount");
		session.setAttribute("ccount", ccount);
		/**
		 * 日志总数量
		 */
		int dcount=dService.checkCount();
		session.removeAttribute("dcount");
		session.setAttribute("dcount", dcount);
		/**
		 * 任务总数量
		 */
		int tcount=tService.checkCount();
		session.removeAttribute("tcount");
		session.setAttribute("tcount", tcount);
		/**
		 * 售后日志总数量
		 */
		int acount=aService.checkCount();
		session.removeAttribute("acount");
		session.setAttribute("acount", acount);
		/**
		 * 总的商机
		 */
		int bcount=bService.checkCount();
		session.removeAttribute("bcount");
		session.setAttribute("bcount", bcount);
		/**
		 * 总的产品
		 */
		int bpcount=bpService.checkCount();
		session.removeAttribute("bpcount");
		session.setAttribute("bpcount", bpcount);
		/**
		 * 今日新增机构
		 */
		
		int tocount=organService.countByToday();
		session.removeAttribute("tocount");
		session.setAttribute("tocount", tocount);
		/**
		 * 今日新增日志
		 */
		int docount=dService.countByToday();
		session.removeAttribute("docount");
		session.setAttribute("docount", docount);
		/**
		 * 今日新增合同
		 */
		int cocount=contractbiz.countByToday();
		session.removeAttribute("cocount");
		session.setAttribute("cocount", cocount);
		/**
		 * 今日新增商机
		 */
		int bocount=bService.countByToday();
		session.removeAttribute("bocount");
		session.setAttribute("bocount", bocount);
		/**
		 * 今日新增售后
		 */
		int aocount=aService.countByToday();
		session.removeAttribute("aocount");
		session.setAttribute("aocount", aocount);
		/**
		 * 今日任务
		 */
		int ttcount=tService.checkCountByToday();
		session.removeAttribute("ttcount");
		session.setAttribute("ttcount", ttcount);
		/**
		 * 今日资料
		 */
		int dfcount=dfService.checkCountBytoday();
		session.removeAttribute("dfcount");
		session.setAttribute("dfcount", dfcount);
		/**
		 * 今日培训资料
		 */
		int tdfcount=dfService.checkCountTrainByToday();
		session.removeAttribute("tdfcount");
		session.setAttribute("tdfcount", tdfcount);
		/**
		 * 今日产品资料
		 */
		int pdfcount=dfService.checkCountProductByToday();
		session.removeAttribute("pdfcount");
		session.setAttribute("pdfcount", pdfcount);
		/**
		 *今日FQA资料
		 */
		int  fdfcount=dfService.checkCountFAQByToday();
		session.removeAttribute("fdfcount");
		session.setAttribute("fdfcount", fdfcount);
		/**
		 * 今日开通触摸屏产品
		 */
		int ccabtcount=contractbiz.checkCountAproductByToday();
		session.removeAttribute("ccabtcount");
		session.setAttribute("ccabtcount", ccabtcount);
		/**
		 * 今日开通专区
		 */
		int ccbbtcount=contractbiz.checkCountBproductByToday();
		session.removeAttribute("ccbbtcount");
		session.setAttribute("ccbbtcount", ccbbtcount);
		/**
		 * 今日开通微刊
		 */
		int cccbtcount=contractbiz.checkCountCproductByToday();
		session.removeAttribute("cccbtcount");
		session.setAttribute("cccbtcount", cccbtcount);
		return "index";
	}
}
